﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ConfigServices;

namespace ConfigReader
{
  public class LayeredConfigReader : IConfigReader
  {
    private readonly IEnumerable<IConfigService> services;
    public LayeredConfigReader(IEnumerable<IConfigService> services)
    {
      this.services = services;
    }

    public string GetValue(string name)
    {
      string value="";
      foreach (var service in services)
      {
        var newValue = service.GetValue(name);
        if (newValue != null&&newValue!=string.Empty)
        {
          value = newValue;
        }

      }
      return value;
    }
  }
}
